/**
 * 驼峰字符串转下划线
 */
export function humpToUnderline(str: string): string {
  return str.replace(/([A-Z])/g, '-$1').toLowerCase()
}

/**
 * 下划线字符串转驼峰
 */
export function underlineToHump(str: string): string {
  if (!str)
    return ''
  return str.replace(/-(\w)/g, (_, letter: string) => {
    return letter.toUpperCase()
  })
}

/**
 * 驼峰转横杠
 */
export function humpToDash(str: string): string {
  return str.replace(/([A-Z])/g, '-$1').toLowerCase()
}

/**
 * 去除字符串的前后空格
 */
export function trim(str: string) {
  return str.replace(/(^\s*)|(\s*$)/g, '')
}
